/**
 * @date 2006-5-9 17:18:24
 *
 */
package org.nanhill.moo.dao.hibernate;

import java.util.List;

import org.nanhill.moo.dao.UserDao;
import org.nanhill.moo.domain.User;
import org.nanhill.support.hibernate.HibernateEntityManager;

/**
 * @author alin [xalinx at gmail dot com]
 * 
 */
public class UserDaoImpl extends HibernateEntityManager<User, Long>
		implements UserDao {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.nanhill.moo.dao.CustomerDao#readCustomer(java.lang.String)
	 */
	public User findByEmail(final String email) {
		return this.findOne("from User p where p.email = ?", email);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.nanhill.moo.dao.CustomerDao#readCustomer(java.lang.String,
	 *      java.lang.String)
	 */
	public User findByEmailPassword(String email, String password) {
		return this.findOne("from User p where p.email = ? and p.password = ?",
				email, password);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.nanhill.moo.dao.UserDao#findLatestPart(int, int)
	 */
	@SuppressWarnings("unchecked")
	public List<User> findLatestPart(int start, int size) {
		return this.findPart("from User p order by id desc", start, size);
	}

}
